/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import MaDictSelect from "@/components/ma-dict-picker/ma-dict-select.vue";
import { page as getPlans } from "$/attractions/broadcast/api/broadcastPlans.ts";
import MaRemoteSelect from "@/components/ma-remote-select/index.vue";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: "计划名称",
      prop: "plan_id",
      render: () => MaRemoteSelect,
      renderProps: {
        api: getPlans,
        apiParams: {
          page: 1,
          pageSize: 1000,
        },
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((plan: any) => ({
              label: plan.plan_name || plan.plan_description || `计划${plan.id}`,
              value: plan.id,
            }));
          }
          return [];
        },
        placeholder: "请选择计划名称",
        clearable: true,
        multiple: false,
        filterable: true,
      },
    },
    {
      label: "执行类型",
      prop: "execution_type",
      render: () => MaDictSelect,
      renderProps: {
        placeholder: "请选择执行类型",
        data: [
          { label: "计划执行", value: 1 },
          { label: "手动执行", value: 2 },
          { label: "应急执行", value: 3 },
        ],
        clearable: true,
        multiple: false,
        filterable: true,
      },
    },
    {
      label: "执行状态",
      prop: "execution_status",
      render: () => MaDictSelect,
      renderProps: {
        placeholder: "请选择执行状态",
        data: [
          { label: "执行中", value: 1 },
          { label: "已完成", value: 2 },
          { label: "失败", value: 3 },
        ],
        clearable: true,
        multiple: false,
        filterable: true,
      },
    },
  ];
}
